#缩写镜像规模

#配置基础镜像和yum源,阶段1：配置环境
FROM centos:7 AS base1
RUN sed -i \
    -e 's|^mirrorlist=|#mirrorlist=|g' \
    -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault|g' \
    -e 's|^baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault|g' \
    /etc/yum.repos.d/CentOS-Base.repo && \
    yum clean all && \
    yum makecache

#安装gcc
RUN yum install -y gcc glibc-static

#拷贝cpp文件到工作目录
ENV WORKDIR=/work
WORKDIR ${WORKDIR}
COPY ./helloworld.c ./

#编译命令
RUN gcc -static -o  helloworld helloworld.c
#CMD ["/work/helloworld"]

#阶段二
FROM busybox
RUN mkdir -p /data
COPY --from=base1 /work/helloworld /data
RUN ls -l /
CMD ["/data/helloworld"]

